package com.yang.designmode.proxy.staticProxy;

import java.util.Date;

/**
 * 代理类
 *  增强目标对象
 *  和目标对象有相同的接口
 *  静态代理
 */
public class CommonProxy implements CommonService{

    private CommonService targetService;

    public CommonProxy(CommonService targetService) {
        this.targetService = targetService;
    }
    @Override
    public String doThing() {
        System.out.println("目标对象执行之前……");
        long start = new Date().getTime();
        System.out.println("代理类执行了……");
        System.out.println("执行耗时：" + (new Date().getTime() - start));
        System.out.println("目标对象执行之后……");
        return targetService.doThing();
    }
}
